// studentMine/suggest/suggest.js
import {
    ajaxPost,
    showToast
} from '../../utils/util'
Page({

    /**
     * 页面的初始数据
     */
    data: {
        cont: '',
        phone: '',
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },
    /**
     * 渲染数据
     */
    changeInput(e) {
        let val = e.detail.value,
            type = e.currentTarget.dataset.type
        if (type == 'phone') {
            this.setData({
                phone: val
            })
        } else {
            this.setData({
                cont: val
            })
        }

    },
    /**
     * 提交信息
     */
    pushInfo() {
        let {
            cont,
            phone
        } = this.data
        if (!cont) {
            showToast('error', '请输入反馈内容')
            return;
        }
        let data = {
            token: wx.getStorageSync('token'),
            content: cont,
            contact: phone,
        }
        ajaxPost('/index/feedback', data, (res) => {
            if (res.code == 0) {
                wx.showToast({
                    title: '提交成功',
                    icon: 'success',
                    duration: 1500,
                    success: () => {
                        setTimeout(() => {
                            wx.navigateBack()
                        }, 1500);
                    }
                })

            } else {

            }

        })
    },
})